package com.zh.note.demo;

import java.util.HashMap;
import java.util.Map;

/**
 * 演示代码使用
 */
public class Demo {

    class Solution {
        public int[] twoSum(int[] nums, int target) {
            Map<Integer, Integer> map = new HashMap<>();
            for (int i = 0; i < nums.length; i++) {
                if (map.containsValue(target - nums[i])) {
                    return new int[]{nums[i], target - nums[i]};
                }
                map.put(i, nums[i]);
            }
            return new int[0];

        }
    }
}
